<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    class Node {
      constructor(element){
        this.element = element
        this.next = null
      }
    }
    class LinkList{
      constructor(){
        this.head = null;
        this.length= 0
      } 
      append(element){
        let node = new Node(element)
        if(this.head ==null){
          this.head = node
        }
        else {
          let tail = this.head
          console.log(tail)
          while(tail.next){
            tail = tail.next
          }
          tail.next = node 
        }
        this.length++
      }
    }
    const linkList = new LinkList()
    linkList.append(1)
    linkList.append(5)
    // linkList.append(4)
    console.log(linkList)
  </script>
</body>
</html>